<?php

namespace Tests\Console;

use App\Models\Permission;
use Tests\TestCase;
use Illuminate\Foundation\Testing\WithFaker;
use Symfony\Component\Console\Exception\RuntimeException;

class CreateRoleTest extends TestCase
{
    use WithFaker;

    public function testSuccess()
    {
        $choice_ask = 'Which permissions assign to this role?';
        \Artisan::command('role:create {name}', function () use ($choice_ask) {
            $this->choice($choice_ask, ['test-view']);
        });
        $role_name = $this->faker->word();
        $this->artisan('role:create ' . $role_name)
            ->expectsQuestion($choice_ask, 'test-view')
            ->assertSuccessful();
    }

    public function testFailed()
    {
        $this->expectException(RuntimeException::class);
        $this->artisan('role:create');
    }
}
